package com.emn.fil.automaticdiscover.ihm.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.emn.fil.automaticdiscover.business.Connection;
import com.emn.fil.automaticdiscover.ihm.Frame;
import com.emn.fil.automaticdiscover.ihm.dialogs.AdvancedCFGDialog;

public class BtnOkDialAdvCfg implements ActionListener{

	private AdvancedCFGDialog my_advanced_frame;
	private Frame my_frame;
	
	public BtnOkDialAdvCfg(AdvancedCFGDialog advancedCFGDialog, Frame myFrame) {
		this.my_advanced_frame = advancedCFGDialog;
		this.my_frame = myFrame;
	}
	
	public void actionPerformed(ActionEvent arg0) {
		// on vide les arraylistes
		this.my_frame.connection.clearArrays();
		// rempli les ports mac
		for(int i=0; i<this.my_advanced_frame.getDlm_ports_mac().size();i++)
			this.my_frame.connection.setPorts_mac_list((Integer)this.my_advanced_frame.getDlm_ports_mac().getElementAt(i));
		// rempli les ports win
		for(int i=0; i<this.my_advanced_frame.getDlm_ports_win().size();i++)
			this.my_frame.connection.setPorts_windows_list((Integer)this.my_advanced_frame.getDlm_ports_win().getElementAt(i));
		// rempli les ports unix
		for(int i=0; i<this.my_advanced_frame.getDlm_ports_unix().size();i++)
			this.my_frame.connection.setPorts_unix_list((Integer)this.my_advanced_frame.getDlm_ports_unix().getElementAt(i));
		// set le timeout
		this.my_frame.connection.setTimeout(this.my_advanced_frame.getTimeout());
		this.my_advanced_frame.dispose();
	}

}
